<?php

/**
 * Description of refreshConsoleAction
\* www.teuker.nl - mail@teuker.nl
 * 
 * @author francisc
 */

class refreshConsoleAction extends sfAction {

    public function execute($request) {

        $reservations = SqlEngine::getConsoleReservations(array(
                                'after_created_at' => $this->getUser()->getAttribute('last_console_message_created_at'),
                                'restaurant_id' => $this->getUser()->getAttribute('current_restaurant_id'),
                                'user_id' => $this->getUser()->getAttribute('user_id')));

        if (empty($reservations))
            return sfView::NONE;

        $this->getUser()->setAttribute('last_console_message_created_at', $reservations[0]['last_created_at']);

        return $this->renderPartial('console_body', array('console_messages'=> $reservations));
    }
}
